import React, {useState} from 'react';

function StateHook() {
    const [count, setCount] = useState(0);
    const [todos, setTodos] = useState([
        {id: 1, text: '学习react-hook'},
        {id: 2, text: '测试'}
    ])
    const todoItems = todos.map((todo) =>
        <li key={todo.id}>
            {todo.text}
        </li>
    );
    return (
        <div className="App">
            <p>{count}</p>
            <h2 onClick={() => setCount(count + 1)}>添加</h2>
            <ul>
                {todoItems}
            </ul>

        </div>
    );
}

export default StateHook;
